<%@page import="model.bean.Chucvu"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String uName = (String) request.getSession().getAttribute("uName");
	String role = (String) request.getSession().getAttribute("role");	
	if((uName == null) || !("admin".equals(role) || !"user".endsWith(role))) {
		response.sendRedirect("login.jsp");
	}
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>ĐỒ ÁN TỐT NGHIỆP</title>
<meta
	content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
	name='viewport'>
<%@ include file="jsheader.jsp"%>
<link href="mycss/popup.css" rel="stylesheet" type="text/css" />
</head>
<body class="skin-blue">
	<%
		String them = (String) request.getAttribute("them");
		String them_menu = (String) request.getAttribute("them_menu");
		String sua = (String) request.getAttribute("sua");
		Chucvu chucvu = (Chucvu) request.getAttribute("chucvu");
	%>
	<!-- header logo: style can be found in header.less -->
	<%@ include file="header.jsp"%>

	<div class="wrapper row-offcanvas row-offcanvas-left">
		<!-- Left side column. contains the logo and sidebar -->
		<%@ include file="menu.jsp"%>

		<!-- Right side column. Contains the navbar and content of the page -->
		<aside class="right-side"> <!-- Content Header (Page header) -->
		<section class="content-header">
		<h1>Quản lý chức vụ</h1>
		<ol class="breadcrumb">
			<li><a href="#"><i class="fa fa-dashboard"></i> Trang chủ</a></li>
			<li><a href="#">Quản lý chức vụ</a></li>
			<li class="active">Thêm mới</li>
		</ol>
		</section> <!-- Main content --> <section class="content">
		<div class="col-md-7">
			<%
				if ("true".equals(them)) {
			%>
			<div class="alert alert-success alert-dismissable">
			<i class="fa fa-info"></i>
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Chúc mừng!</b> Thêm mới chức vụ thành công!
			</div>
			<%
				} else if ("false".equals(them)) {
			%>
			<div class="alert alert-danger alert-dismissable">
			<i class="fa fa-info"></i>
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Xin lỗi</b> Thêm mới không thành công!
			</div>
			<%
				}
			%>
			<div class="alert alert-danger alert-dismissable" style="display: none" id="ktdl" >
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Lỗi</b> Chưa nhập dữ liệu!
			</div>
		</div>

		<div class="row">
			<!-- left column -->
			<div class="col-md-7">
				<!-- general form elements -->
				<div class="box box-primary">
					<!-- /.box-header -->
					<!-- form start -->

					<form action="ChucvuServlet" method="post" name="mform">
						<div class="box-body">
							<div class="form-group">
								<label>Tên chức vụ:</label> <input class="form-control"
									type="text" placeholder="Nhập vào tên chức vụ" name="tencv"
									id="tencv">
								<!-- /.form group -->
							</div>
						</div>

						<!-- Element to pop up -->
						<div id="element_to_pop_up">
							<a class="button b-close">X</a>
							<h4>Bạn có chắc chắn muốn thêm không?</h4>
							<a href="#" onclick="them()"><span class="button small pop1">Đồng
									ý</span></a> <a href="#" onclick="popupclose()"><span
								class="button small pop1">Hủy</span></a>
						</div>
					</form>
					<div class="box-footer">
							<button class="btn btn-success" onclick="popup()">Thêm
								mới</button>
							<a href="ChucvuServlet?boqua" class="btn btn-primary">Bỏ qua</a>
				    </div>					
				</div>
				<!-- /.box -->
				<!-- Form Element sizes -->
			</div>
			<!--/.col (left) -->
		</div>
		<!-- /.row --> </section><!-- /.content --> </aside>
		<!-- /.right-side -->
	</div>
	<!-- ./wrapper -->
	<!-- jQuery 2.0.2 -->
	<script src="js/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="js/bootstrap.min.js" type="text/javascript"></script>
	<!-- InputMask -->
	<script src="js/plugins/input-mask/jquery.inputmask.js"
		type="text/javascript"></script>
	<script src="js/plugins/input-mask/jquery.inputmask.date.extensions.js"
		type="text/javascript"></script>
	<script src="js/plugins/input-mask/jquery.inputmask.extensions.js"
		type="text/javascript"></script>
	<script src="js/AdminLTE/app.js" type="text/javascript"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="js/AdminLTE/demo.js" type="text/javascript"></script>
	<!-- Page script -->
	<%@include file="footer.jsp"%>

	<script type="text/javascript">
		function popup() {			
			var tencv = document.getElementById('tencv').value;
			if(tencv == "") {
				document.getElementById('ktdl').style.display='block';
			} else {
				document.getElementById('ktdl').style.display='none';
				$('#element_to_pop_up').bPopup({
					speed : 650,
					transition : 'slideIn',
					transitionClose : 'slideBack'
				});
			}		
		}	
		
		function them() {
			document.forms["mform"].submit();			
		}
		
		function popupclose() {
			$('#element_to_pop_up').bPopup().close();
		}
	</script>
</body>
</html>